const { init, default: send_msg, listen } = require('../../atom/mqtt');
import regeneratorRuntime from '../../libs/regenerator-runtime';

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {

    const app = getApp();
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo
      });
      this.setData({
        hasUserInfo: true
      });
    }
    const res = await send_msg('diting', 'dataservice.nodejs', {
      condition: {},
      modelid: 'custom::js_' + 'compiling_find',
      spaceid: 'diting'
    }, 4000);
    console.warn('----- res -----', res);

  },
  getUserInfo: function (e) {
    console.log(e);
    const app = getApp();
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
